<template>
  <div id="app">
    <el-table
      :data="tableData"
      style="width: 100%"
      max-height="900">
      <el-table-column
        prop="id"
        label="id"
        width="50">
      </el-table-column>
      <el-table-column
        prop="customer"
        label="被委托人"
        width="180">
      </el-table-column>
      <el-table-column
        prop="title"
        label="标题"
        width="300">
      </el-table-column>
      <el-table-column
        label="操作"
        min-width="120">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="ToEvaluation(scope.row.id)">评价</el-button>
          <el-button type="primary" size="mini" @click="ToComplaint(scope.row.id)">投诉</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import router from '../../router'

export default {
  name: 'MyFinishedTask',
  data () {
    return {
      tableData: []
    }
  },
  methods: {
    ToEvaluation (id) {
      return this.$router.push({
        path: '/Evaluation',
        name: 'Evaluation',
        params: {
          id: id
        }
      })
    },
    ToComplaint (id) {
      return this.$router.push({
        path: '/Complaint',
        name: 'Complaint',
        params: {
          id: id
        }
      })
    },
    getObj () {
      this.$axios({
        url: `user/task/hasfinishedtask`,
        method: 'get',
        data: {}
      }).then(res => {
        if (res.data.status === 100) {
          this.tableData = res.data.data
          for (var i = 0; i < res.data.data.length; i++) {
            if (res.data.data[i].tag_id === 1) {
              res.data.data[i].tag_id = '快递代取'
            }
            if (res.data.data[i].tag_id === 2) {
              res.data.data[i].tag_id = '事务代办'
            }
          }
        } else {
          alert('获取任务列表失败')
        }
      }).catch(err => {
        alert(err)
        router.replace('/login')
      })
    },
    readTask (id) {
      return this.$router.push({
        path: '/ReadTask',
        name: 'ReadTask',
        params: {
          id: id
        }
      })
    },
    handleClick (tab, event) {
      console.log(tab, event)
    }
  },
  created () {
    this.getObj()
  }
}
</script>

<style scoped>

</style>
